package com.jiudengnile.liushu.biz.bo;

import com.jiudengnile.liushu.biz.domains.BaseUserDO;
import com.jiudengnile.liushu.biz.domains.permission.PermissionDO;
import com.jiudengnile.liushu.biz.domains.permission.PermissionUserDO;
import com.jiudengnile.liushu.biz.query.ListWithTotalCount;
import com.jiudengnile.liushu.biz.query.PermissionQuery;

/**
 * 权限相关操作
 * @author pister
 * 2012-9-8 下午05:53:54
 */
public interface PermissionBO {
	
	/**
	 * 判断用户是否有该权限
	 * @param userId
	 * @param permissionCode
	 * @return
	 */
	boolean hasPermission(long userId, String permissionCode);
	
	/**
	 * 获得用户的操作权限
	 * @param permissionQuery
	 * @return
	 */
	ListWithTotalCount<PermissionDO> getPermissionByUser(PermissionQuery permissionQuery);
	
	/**
	 * 根据权限id获有该权限的用户
	 * @param permissionQuery
	 * @return
	 */
	ListWithTotalCount<BaseUserDO> getUserByPermission(PermissionQuery permissionQuery);
	
	/**
	 * 获取权限列表
	 * @param permissionQuery
	 * @return
	 */
	ListWithTotalCount<PermissionDO> getPermissionForPage(PermissionQuery permissionQuery);
	
	/**
	 * 通过code获取权限
	 * @param code
	 * @return
	 */
	PermissionDO getPermissionByCode(String code);
	
	/**
	 * 根据id获得权限
	 * @param id
	 * @return
	 */
	PermissionDO getPermissionById(long id);
	
	/**
	 * 创建权限
	 * @param permissionDO
	 * @return 刚刚创建的权限id
	 */
	long createPermission(PermissionDO permissionDO);
	
	/**
	 * 把某个权限关联用户
	 * @param permissionUserDO
	 * @return
	 */
	long createPermissionUser(PermissionUserDO permissionUserDO);
	
}
